package cn.com.code.hwjs;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * 配置文件恢复
 * https://www.nowcoder.com/practice/ca6ac6ef9538419abf6f883f7d6f6ee5?tpId=37&tqId=21289&rp=1&ru=/exam/oj&qru=/exam/oj&sourceUrl=%2Fexam%2Foj%3Fdifficulty%3D3%26page%3D1%26pageSize%3D50%26search%3D%26tab%3D%25E5%2590%258D%25E4%25BC%2581%25E7%25AC%2594%25E8%25AF%2595%25E7%259C%259F%25E9%25A2%2598%26topicId%3D37&difficulty=3&judgeStatus=undefined&tags=&title=
 *
 * @author zhengpei
 * @date 2022/5/6
 */
public class Hwjs66 {
  private static Map<String, String> map = new HashMap<>();

  static {
    map.put("reset", "reset what");
    map.put("reset board", "board fault");
    map.put("board add", "where to add");
    map.put("board delete", "no board at all");
    map.put("reboot backplane", "impossible");
    map.put("backplane abort", "install first");
    map.put("he he", "unknown command");
  }

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
      String str = scanner.nextLine();
      command(str);
    }
  }

  private static void command(String str) {
    String[] arr = str.split(" ");
    if (arr.length == 1) {
      if ("reset".contains(str)) {
        System.out.println(map.get("reset"));
      } else {
        System.out.println("unknown command");
      }
    } else {
      String result = "unknown command";
      int count = 0;
      for (String key : map.keySet()) {
        if (key.equals(str)) {
          result = map.get(str);
          break;
        } else {
          String[] split = key.split(" ");
          if (split.length > 1 && split[0].indexOf(arr[0]) == 0 && split[1].indexOf(arr[1]) == 0) {
            result = map.get(key);
            count++;
          }
        }
      }
      System.out.println(count > 1 ? "unknown command" : result);
    }
  }

}
